package com.cnpinxi.controller.web.messageBoard;

import com.cnpinxi.controller.base.BaseController;
import com.cnpinxi.domain.MessageBoard;
import com.cnpinxi.result.ResultObj;
import com.cnpinxi.service.MessageBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * Created by lutao on 2017/7/14.
 */
@RequestMapping("/messageBoard")
@Controller
public class MessageBoardController extends BaseController {

@Autowired
    MessageBoardService messageBoardService;
    /**
     * 编辑产品名称
     * @param messageBoard
     * @return
     */
    @RequestMapping(value = "/addMessageBoard")
    @ResponseBody
    public String addMessageBoard(MessageBoard messageBoard){
        ResultObj resultObj = new ResultObj();
        resultObj.setCode(ResultObj.CODE_SUCCESS);
        try {
            messageBoard.setCreateTime(new Date());
            messageBoard.setStatus(MessageBoard.STATUS_UNRETURN);
            messageBoardService.insertMessageBoard(messageBoard);
            resultObj.setMsg("操作成功！");
        } catch (Exception e) {
            resultObj.setCode(ResultObj.CODE_FAIL);
            resultObj.setMsg(e.getMessage());
            e.printStackTrace();
        }
        return resultObj.toJson();
    }


}
